<template>
	<view class="container">
		<view class="header uni-flex uni-row flex-between back">
			<uni-nav-bar title="使用帮助">
				<template slot='left'>
					<view class="flex width-100" @click='goBack'>
						<i class='iconfont iconfanhui'></i>
					</view>
				</template>
			</uni-nav-bar>
		</view>
		<web-view :src="url"></web-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				viewerUrl: '/hybrid/html/web/viewer.html',
				// fileUrl: 'http://192.168.1.248:9002/zdhjc/help/%E9%A1%B9%E7%9B%AE%E5%85%A8%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E7%AE%A1%E7%90%86APP%E4%BD%BF%E7%94%A8%E6%89%8B%E5%86%8C.pdf',
				fileUrl: 'http://124.71.9.150:81/zdhjc/help/%E3%80%90%E6%93%8D%E4%BD%9C%E6%89%8B%E5%86%8C%E3%80%91%E8%87%AA%E5%8A%A8%E5%8C%96%E7%9B%91%E6%B5%8B%E5%B7%A5%E7%A8%8B%E9%A1%B9%E7%9B%AE%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9Fv2.2.1.pdf',
				url: ''
			};
		},
		onLoad(data) {
			let height = 0;
			uni.getSystemInfo({
				success: (res) => {
					height = res.windowHeight - 60;
				}
			});
			var currentWebView = this.$scope.$getAppWebview();
			// let currentWebView = plus.webview.currentWebview();
			setTimeout(function() {
				var wv = currentWebView.children()[0];
				wv.setStyle({ //设置web-view距离顶部的距离以及自己的高度，单位为px
					top: 80,
					height: height
				})
			}, 1000);
			// 判断是手机系统：安卓，使用pdf.js
			if (plus.os.name === 'Android') {
				// this.url = `${this.viewerUrl}`;
				this.url = `${this.viewerUrl}?file=${encodeURIComponent(this.fileUrl)}`;
			}
			//ios，直接访问pdf所在路径
			else {
				this.url = encodeURIComponent(this.fileUrl);
			}
		},
		methods: {}
	};
</script>

<style>
	.back {
		position: fixed;
		z-index: 998;
	}
</style>
